<{include file="head.html"}>
<script>
    function rm(id){
        $.ajax({
            url:'<{$config.SITE_URL}>/ajax.php?action=buy&m=rm&va='+id,           
            error:function(){
                alert('删除失败');
            },
            cache:false,
            success:function(html){
                if(html=="ok"){
                    $("#commo_"+id).remove();
                }else{
                    alert(html);
                }
            }
        })
        
    }
    function up(c,id){
        if(isNaN(c)){
            alert('非法字符，请输入正整数');
            return;
        }
        if(c<=0){
            alert('至少1件');
            return;
        }
        vl=($("[name='commo["+id+"][price]']").val())*c;
    
        
        $("#t_"+id).html(vl);
        
    }
</script>
<div class="public_main">              
    <div class="mbox">
        <div class="mt">
            您的购物车列表
        </div>
        <div class="md">
            
            <{if $commos|count > 0}>
            <form method="post">
                <table frame="box" cellspacing="1" border="1px" style="border:none;width:80%;margin:15px auto;">
                    <tr><td width="40%">宝贝名</td><td width="20%">购买数量</td><td width="20%">价格</td><td width="20%" align="center">操作</td></tr>
                <{foreach $commos as $v}>               
                <tr id="commo_<{$v.id}>" >
                <input type="hidden" name="commo[<{$v.id}>][id]" value="<{$v.id}>"/>
                <input type="hidden" name="commo[<{$v.id}>][price]" value="<{if $v.discount>0}><{$v.vprice*$v.discount/10}><{else}><{$v.vprice}><{/if}>"/>
                    <td><{$v.name}></td>
                    <td><input type="text" value="<{$v.count}>" style="width: 30px;" name="commo[<{$v.id}>][count]" onkeyup="up(this.value,<{$v.id}>)"/></td>
                    <td id="t_<{$v.id}>"><{if $v.discount>0}><{$v.count*$v.vprice*$v.discount/10}><{else}><{$v.vprice*$v.count}><{/if}></td>
                    <td style="text-align: center"><a href="javascript:void(0)" onclick="rm(<{$v.id}>)">删除</a></td>
                </tr>
                
                
                <{/foreach}>
                <tr>
                    <td colspan="4" style="text-align: right;margin:10px;border:none;"><input type="submit" name="mkorder" value="提交订单" /></td>
                </tr>
                </table>
                
            </form>
            <{else}>
            您的购物车内还没有宝贝
            <{/if}>
        </div> 
    </div>
</div>
<{include file="foot.html"}>
